﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site/Master/Main.Master" AutoEventWireup="true"
    CodeBehind="Shopping1.aspx.cs" Inherits="ECommerce.Web.Site.Shopping1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="styles/shoppingone.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function Increase(sender,price)
        {

            var val = parseInt($(sender).prev().val());
            if (val < 99)
            {
                $(sender).prev().val(val + 1);

                var totalPrice = parseFloat($("#emTotalPrice").text().replace("￥", ""));
                var productCount = parseInt($("#emProductCount").text());

                totalPrice += price;
                productCount += 1;

                var str = "￥" + totalPrice;
                if (str.indexOf(".") == -1)
                {
                    str += ".00";
                }
                $("#emTotalPrice").text(str);
                $("#emProductCount").text(productCount)
            }

        }

        function Decrease(sender,price)
        {
            var val = parseInt($(sender).next().val());
            if (val > 1)
            {
                $(sender).next().val(val - 1);

                var totalPrice = parseFloat($("#emTotalPrice").text().replace("￥", ""));
                var productCount = parseInt($("#emProductCount").text());

                totalPrice -= price;
                productCount -= 1;
                var str = "￥" + totalPrice;
                if (str.indexOf(".") == -1)
                {
                    str += ".00";
                }
                $("#emTotalPrice").text(str);
                $("#emProductCount").text(productCount)
            }

        }

        function buy_blur(sender)
        {
            var value = parseInt($(sender).val());
            if (isNaN(value))
            {
                alert("数据格式不正确");
                $(sender).val(1);
            }
            else
            {
                if (value < 1 || value > 99)
                {
                    alert("购买数量应在1到99之间");
                    if (value < 1)
                    {
                        $(sender).val(1);
                    }
                    else if (value > 99)
                    {
                        $(sender).val(99);
                    }
                }
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:Literal ID="Literal1" runat="server"></asp:Literal>
    <div id="main">
        <div class="shopping">
            <p>
                <span class="tl">1.查看购物车</span><span>2.填写核对信息单</span><span>3.成功提交订单</span></p>
            <h1>
                <img src="images/Sbg1.jpg" /></h1>
            <ul>
                <li class="title"><span class="one">商品</span><span class="two">编号</span><span class="three">名称</span>
                    <!--<span class="four">尺寸</span>--><span class="five">原价</span><span class="six">现价</span>
                    <span class="seven">修改数量</span><span class="eight">操作</span> </li>
                <asp:Repeater ID="rpt" runat="server" onitemcommand="rpt_ItemCommand">
                    <ItemTemplate>
                        <li class="content"><span  class="one">
                            <img src='<%#Eval("SmallImageAbsPath") %>' style="width:62px; height:62px;" alt="" />                           
                        </span><span class="two">
                            <asp:Literal ID="litID" runat="server" Text='<%#Eval("ID") %>'></asp:Literal></span><span class="three"><%#Eval("Name") %></span>
                            <!--<span class="four">
                                <asp:Literal ID="litSize" runat="server" Text='<%#Eval("Size") %>'></asp:Literal></span>--><span class="five"><%#Eval("OldPrice","{0:c2}") %></span><span class="six"><%#Eval("CurrentPrice","{0:c2}") %></span>
                                <span class="seven">
                                 <asp:LinkButton ID="btnDecrease" CommandName="Decrease" CommandArgument='<%#Eval("CurrentPrice") %>' runat="server"><img src="images/Sbg-04.jpg" /></asp:LinkButton>
                                <%--<a href="javascript:;" onclick="Decrease(this,<%#Eval("CurrentPrice") %>);"></a>--%>
                                <asp:TextBox ID="txtBuyCount" runat="server" CssClass="sum" Text='<%#Eval("BuyCount") %>' onblur="buy_blur(this)" ></asp:TextBox>
                                 <asp:LinkButton ID="btnIncrease" CommandName="Increase" CommandArgument='<%#Eval("CurrentPrice") %>' runat="server"><img src="images/Sbg-05.jpg" /></a></asp:LinkButton>
                                   <%-- <a href="javascript://" onclick="Increase(this,<%#Eval("CurrentPrice") %>);">--%>
                                         </span>
                            <asp:LinkButton ID="LinkButton1" runat="server" CssClass="eight" CommandName="Delete" CommandArgument='<%#Eval("ID") %>' >删除</asp:LinkButton>
                        </li>
                    </ItemTemplate>
                </asp:Repeater>                
                
                <li class="account"><span>产品数量总计<em id="emProductCount"><asp:Literal ID="litProductCount" runat="server"></asp:Literal></em>件</span> <span>产品金额总计<em id="emTotalPrice"><asp:Literal
                    ID="litTotalPrice" runat="server"></asp:Literal></em></span></li>
                <li class="allbut"><span class="left">
                    <asp:LinkButton ID="btnClear" runat="server" onclick="btnClear_Click"><img src="images/Sbg-08.jpg" align="middle" />&nbsp;清空购物车</asp:LinkButton></span> <span class="right"><a href="ProductList.aspx">
                        <img src="images/Sbg-06.jpg" /></a> 
                        <asp:LinkButton ID="lnkNext" runat="server" onclick="lnkNext_Click"> <img src="images/Sbg-07.jpg" /></asp:LinkButton>
                        </span> </li>
            </ul>
        </div>
    </div>
</asp:Content>
